Skip to content

[IsoSession] Add the isolation_session network test baseline - #1796

Open
Ion Vasilian (ionvasilian) wants to merge 1 commit into
mainfrom
user/ionv/isolation-session-network-test-pass
Open

Ion Vasilian (ionvasilian) wants to merge 1 commit into
mainfrom
user/ionv/isolation-session-network-test-pass

Conversation

@ionvasilian

@ionvasilian Ion Vasilian (ionvasilian) commented Nov 18, 2026 •

Copy link
Copy Markdown

Summary

This PR adds a network test pass for the isolation_session backend. It is a
baseline that later changes light up row by row. It changes no product code.

  • tests/scripts/run_isolation_session_network_test.ps1 (new). It has 35
    rows adapted from the process_container network areas:

    • capability matrix
    • model-3 equivalence
    • egress rules
    • host loopback
    • proxy

    The WSLC GA-egress matrix is the row template where it fits. Row groups:

    • A01-A04 on/off.
    • E01-E13 L3/L4 egress. E13 checks that the link-local metadata address
      169.254.169.254 is never reachable, whatever the policy allows.
    • L01-L11 host loopback.
    • P01-P03 bring-your-own proxy.
    • X01-X04 rejection surface.
  • The TestBundle build (pipeline template and
    build-windows-sdk-test-bundle.ps1) stages the script.

  • An invalid v1.1.0-alpha fixture,
    isolation_session_declared_loopback_ports.json.

Outcome vocabulary

Each row runs the shipping wxc-exec and is judged at runtime. There is no
build flag or lab switch.

Outcome Meaning
PASS The row was admitted and the in-sandbox probe shows exactly the requested posture. For X rows, the invalid request was rejected.
UNSUPPORTED The row was rejected with the named isolation_session network rejection. The row reports the capability it needs, for example defaultDeny, loopbackPorts or egressRules.
FAIL The row was admitted but the posture was narrower or broader than requested, or it hit any other error.
KNOWN-GAP Reserved for a recorded gap: a killed wxc-exec can leak its agent user.

When a later change admits a shape, its row starts enforcing without any edit
to the script.

Consumer

The Windows integration tests consume the IsolationSession TestBundle through
the MXC package. Landing order:

  1. This PR and the package.
  2. The consumer row and package bump.

The script follows that harness's contract:

  • It is called with -WxcExePath/-ConfigDir.
  • It prints the summary line <n>/<m> passed.
  • In session 0, or when the backend is unavailable, it prints SKIPPED: and
    exits 0.
  • It exits nonzero only when a row fails.

Validation

  • Contract suites (shipping build):
    • v0.9.0-alpha: 278 passed
    • v1.0.0: 281 passed
    • v1.1.0-alpha: 390 passed
    • version boundaries: 21 passed
  • cargo test --lib: 2822 passed, 1 ignored, 1 failure.
    • The failure is host_to_container_loopback_connects (10060). It is
      unrelated to this PR and also fails without it.
  • Script checks:
    • parses on Windows PowerShell 5.1
    • ASCII only
    • quoting/process-management lint clean
  • Runtime, on a prerelease Windows VM as the interactive console user:
    • Network default deny off: 5 PASS (A01, X01-X04), 30 UNSUPPORTED,
      0 FAIL.
    • Network default deny on: A01 FAIL (0x800402B0). On that prerelease
      build a start without network options is restricted. This is on the OS
      side: the platform will keep host networking for a start without network
      options, and A01 will pass then. The other 34 rows are unchanged.
    • After each run, no agent users, processes or tasks were left behind.

@ionvasilian
Ion Vasilian (ionvasilian) requested a review from a team November 18, 2026 00:02
@ionvasilian
Ion Vasilian (ionvasilian) requested a review from a team as a code owner November 18, 2026 00:02
Copilot AI balanced review requested due to automatic review settings November 18, 2026 00:02
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new validation can falsely pass rejection and runtime failures, is not invoked by CI, and directly changes machine-wide settings instead of using caller-managed setup.

5 open issues
What changed in this PR

Adds network-policy validation coverage for MXC’s IsolationSession backend and a compile-time lab gate for exact TCP loopback ports, while preserving shipping admission rules.

Changes:

  • Adds 31 shipping/lab admission cases, a build-mode canary, and optional runtime reachability and cleanup checks.
  • Adds lab-only backend and parser handling, with corresponding test adjustments.
  • Packages the script in Windows test bundles, with optional staging for older Azure branches.

Validation was limited to code inspection; Windows runtime tests were not run.

File Description
tests/​scripts/​run_isolation_session_network_test.ps1 Adds admission, reachability, and cleanup checks.
src/​mxc-sdk/​src/​policy/​sdk_v1_conformance.rs Skips one parser-rejection fixture in lab builds.
src/​mxc-sdk/​src/​policy.rs Makes an explicit-network test shipping-only.
src/​mxc-sdk/​src/​core/​mxc_contract/​published/​v1_0_0/​request.rs Defers non-proxy network validation to the backend in lab builds.
src/​mxc-sdk/​src/​core/​mxc_contract/​published/​v0_9_0_alpha/​request.rs Applies the same lab-only parser deferral.
src/​mxc-sdk/​src/​core/​mxc_contract/​dev/​request.rs Applies lab-only parser deferral to the development contract.
src/​mxc-sdk/​src/​core/​mxc_common/​config_parser.rs Disables two parser-rejection tests under the lab cfg.
src/​mxc-sdk/​src/​backends/​isolation_session/​common/​policy.rs Adds the narrow loopback admission gate and tests.
src/​mxc-sdk/​src/​backends/​isolation_session/​common/​one_shot.rs Enables validated egress rules in lab builds and adds tests.
src/​mxc-sdk/​Cargo.toml Registers the lab cfg for compiler checking.
scripts/​ci/​build-windows-sdk-test-bundle.ps1 Stages and requires the new script in SDK test bundles.
.azure-pipelines/​templates/​IsolationSession.TestBundle.Build.Job.yml Stages the script when present on the selected branch.

Review effort: Balanced

@ionvasilian
Ion Vasilian (ionvasilian) force-pushed the user/ionv/isolation-session-network-test-pass branch from b7bd3f4 to 1a3f09b Compare November 18, 2026 00:20
Copilot AI balanced review requested due to automatic review settings November 18, 2026 00:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Lab enforcement relies on external OS-private configuration, and revised runtime probes were not rerun, requiring maintainer verification of enforcement, restoration, and cleanup on a compatible prerelease Windows host.

No open issues 🎉

5 resolved since last review

Review effort: Balanced

@ionvasilian

Ion Vasilian (ionvasilian) commented Nov 18, 2026 •

Copy link
Copy Markdown
Author

Superseded: these results are for 1a3f09b. 83d1575 removed the runtime rows from this PR; see the review discussion.

Re-ran the runtime rows at 1a3f09b on a pre-release Windows build, to address the review note that the revised probes had not been re-run.

Command: run_isolation_session_network_test.ps1 -Lab -Runtime -RuntimeSetupScript <host setup> -WxcExePath <lab wxc-exec>. It ran in an interactive user session, not a service session.

Result: 40/40 passed (exit 0).

  • Admission: 31/31
  • Runtime: R01 external TCP denied, R02 external UDP denied, R03 undeclared loopback port denied, R04 ::1 on declared port denied, R05 declared port with host listener down, R06 declared loopback port reachable, R07 DNS resolution denied, R08 session exited cleanly, R99 no leaked session resources: all PASS.

Restoration and cleanup, checked independently after the run:

  • The host setup script's Restore removed every value it had set; none remained.
  • No relay, wxc-exec or test processes were left.
  • The agent-user count matched the pre-run baseline.

Scope note: the host enforcement comes from an external, OS-side setup script that this PR does not ship. The lab cfg is not part of shipping builds, and the shipping admission rows (CI dry-run) do not depend on it.

@adpa-ms adpa-ms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AgentAssisted] A few questions about the PR's purpose before the details. The answers decide its shape.

1. What has to work that doesn't today? MXC passes no network policy to the OS. The IsolationSession bindings have no network members, and the create-and-run path passes none to add_user, start_session or create_process. As your comment says, the enforcement comes from the host setup script. On a host it has prepared, would a shipping wxc-exec with the all-allow request get the same results as the -Lab -Runtime rows? If so, what does the lab build add?

2. Why land the runtime rows in MXC now? ProcessContainer's network tests fit here: MXC builds the requested rules into the spec it passes to CreateProcessSecurityEnvironment, so the tests cover MXC's translation too. Here MXC passes nothing yet. These rows' network results depend only on the OS and the setup script, and neither MXC CI nor the planned OS row runs them. Should they land with the public network surface MXC will pass the policy through, and run on the OS side until then?

3. Why change the published 0.9.0-alpha and 1.0.0 parsers? A release wxc-exec accepts 1.1.0-alpha IsolationSession requests without --experimental, and the script chooses its own version. Three of the four test exemptions exist only because the published parsers changed. Under the lab cfg, the invalid-fixture and missing-network tests in mxc_contract_v0_9_0_alpha and mxc_contract_v1_0_0 would also fail; the --lib run doesn't build them. Does any caller need a published contract?

4. What do the shipping dry-run rows catch that existing tests miss? PR CI already enforces the rule: contract tests and fixtures for all three versions, plus config parser, SDK and backend unit tests. The nightly one-shot suite checks it against the real binary. In a shipping build, 27 of the 31 rows expect the same parser message. A dry run stops before any OS call, so these rows test nothing specific to an IsolationSession host.

A smaller shape, depending on your answers:

  • To measure the compartment before the public surface exists, an OS-side test can launch the shipping wxc-exec with the all-allow request. That needs no MXC change.
  • If MXC must accept the restricted request now, gate only the dev contract and the backend. The dev parser accepts exactly all-allow or the loopback shape, and the script sends 1.1.0-alpha. No test needs an exemption: none of the dev contract's invalid fixtures has the loopback shape.
  • Drop the shipping rows. To pin that shipping builds reject the loopback shape, add one invalid fixture.

@ionvasilian
Ion Vasilian (ionvasilian) force-pushed the user/ionv/isolation-session-network-test-pass branch from 1a3f09b to 83d1575 Compare November 18, 2026 22:50
Copilot AI balanced review requested due to automatic review settings November 18, 2026 22:50
@ionvasilian Ion Vasilian (ionvasilian) changed the title [IsoSession] Network policy capability test pass and lab-only loopback gate [IsoSession] Network policy admission pass and lab-only loopback gate Nov 18, 2026
@ionvasilian

Copy link
Copy Markdown
Author

adpa-ms thanks; points 1-4 accepted. Reshaped per your proposal (83d1575): dev contract (1.1.0-alpha) and backend only, published parsers untouched, shipping rows replaced by one invalid fixture. Runtime rows run OS-side until MXC passes the public network options, then land in MXC with that change.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test script skips the shipping-mode admission checks and lacks the runtime path needed to reproduce the claimed reachability, process-exit, and resource-cleanup validation.

2 open issues

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The checks cover admission only, leaving the private, external host setup and exact-port OS enforcement, including Windows runtime behavior, for a maintainer to verify.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@MGudgin Gudge (MGudgin) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gudge needs more time to review this PR before it is merged. Please hold off on merging until that review is complete.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback Waiting for additional information or action from the issue or pull-request author. label Nov 19, 2026

@adpa-ms adpa-ms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AgentAssisted] Thanks: the reshape resolves points 2–4. The runtime rows are gone, the published contracts are untouched, and one fixture replaces the shipping rows.

Point 1 is still open, and it decides whether the lab gate belongs in this PR. MXC still passes no network policy to the OS. A lab binary with the loopback request makes the same OS calls as a shipping binary with the all-allow request. The gate changes what MXC accepts, not what the session enforces.

With the runtime rows gone, who needs a lab build to accept the restricted request before MXC can apply its policy, and for what?

If nothing needs it sooner, could the gate land with the change that passes the public network options to the session, as the runtime rows will? That change is what makes MXC apply the policy the gate admits.

If something needs it sooner, a narrower gate would be enough. In lab builds, the dev parser would accept only all-allow or the loopback shape, and everything else would keep the shipping message. Today, lab builds skip the parser's network check for any request without a proxy. That turns two invalid fixtures into valid all-allow requests: isolation_session_egress_allow_rules.json and isolation_session_egress_deny_rules.json. Normalization treats their empty allow and deny lists as absent.

Add tests/scripts/run_isolation_session_network_test.ps1, a network test
pass for the isolation_session backend. Its 35 rows are adapted from the
process_container network areas (capability matrix, model-3 equivalence,
egress rules, host loopback, proxy), using the WSLC GA-egress matrix as
the row template where it fits.

Each row runs the shipping wxc-exec, and its outcome is judged at
runtime; there is no build flag:
- admitted: the probe inside the sandbox must show the requested posture
  (reachable where allowed, blocked where denied). Admitted but narrower
  or broader than requested is FAIL.
- rejected with the named isolation_session network rejection:
  UNSUPPORTED, reported with the capability it needs. Any other error is
  FAIL.
- KNOWN-GAP only for a recorded gap (a killed wxc-exec can leak its agent
  user).
When a later change admits a shape, its row starts enforcing without
editing the script. On today's MXC the all-allow row passes and every
restricted row reports UNSUPPORTED.

Row E13 pins that the link-local metadata address 169.254.169.254 is
never reachable: an explicit allow of 169.254.0.0/16 must be rejected
(linkLocal) or, if admitted, the probe to 169.254.169.254:80 must be
blocked.

The script skips in session 0 and where the backend is unavailable, and
prints the summary line the Windows integration harness parses.

The TestBundle build stages the script (optional on older bundled
branches), so the Windows integration tests that consume the bundle can
run it.

Add the invalid v1.1.0-alpha fixture
isolation_session_declared_loopback_ports.json, which pins that a
declared-loopback shape is rejected today.

No product code changes.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 9e4e00d4-9956-456c-93ca-1c66128be594
@ionvasilian
Ion Vasilian (ionvasilian) force-pushed the user/ionv/isolation-session-network-test-pass branch from 83d1575 to ce3e187 Compare November 19, 2026 05:02
Copilot AI balanced review requested due to automatic review settings November 19, 2026 05:02
@ionvasilian Ion Vasilian (ionvasilian) changed the title [IsoSession] Network policy admission pass and lab-only loopback gate Add the isolation_session network test baseline Nov 19, 2026
@ionvasilian

Copy link
Copy Markdown
Author

adpa-ms Thanks. On point 1: you were right that a build-flag gate in product code with
no consumer, loosening the dev contract, was the wrong shape. I've reshaped the
PR. It is now a test-only baseline:

  • No product code, no build flag, and no contract or parser change.
  • One network test script (35 rows) whose rows run the shipping wxc-exec and are
    judged at runtime:
    • Admitted rows must show exactly the requested posture.
    • A rejected row reports UNSUPPORTED with the capability it needs.
    • Anything else is a FAIL.
  • On today's MXC the all-allow row passes and every restricted row reports
    UNSUPPORTED.
  • The consumer is the Windows integration test suite, which runs the
    IsolationSession TestBundle from the MXC package. That is why the bundle now
    stages the script.

Later PRs will regenerate the bindings and then pass the network options. As
each shape is admitted, its row starts enforcing without any edit to the
script. Those changes are reviewable on their own.

@microsoft-github-policy-service microsoft-github-policy-service Bot added Needs-Attention Requires attention or a decision from the MXC maintainers. and removed Needs-Author-Feedback Waiting for additional information or action from the issue or pull-request author. labels Nov 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Network tests can produce false passes or failures due to incomplete UDP/reset verification, incorrect expectations for invalid proxy policies, and a missing host reachability control for the metadata endpoint.

4 open issues

Review effort: Balanced

Comment on lines +299 to +301
$u.Connect($addr, $port)
[void]$u.Send([byte[]](1, 2, 3), 3)
"PROBE $name SENT"
Comment on lines +481 to +485
@{ Id = 'P01'; Area = 'proxy'; Cap = 'networkProxy with all-allow'; Needs = 'runtimeProxy'
Net = $AllowAll; Rc = @{ networkProxy = $proxyUrl }; Allow = @('external', 'udp', 'declared', 'other') }
@{ Id = 'P02'; Area = 'proxy'; Cap = 'networkProxy with its port declared'; Needs = 'loopbackPorts'
Net = (DenyDefault -Allow @(Rule -Cidr $Lo -Protocol tcp -Port $D)); Rc = @{ networkProxy = $proxyUrl }
Allow = @('declared') }
"Test-Tcp 'linklocal' '169.254.169.254' 80 `$null",
"Test-Udp 'udp' '$ExternalAddress' 53",
"Test-Dns 'dns' '$DnsName'",
"Test-Tcp 'down' '127.0.0.1' $downPort `$null",
Comment on lines +544 to +545
$ok = $pv.Ok
$why = $pv.Why
@ionvasilian Ion Vasilian (ionvasilian) changed the title Add the isolation_session network test baseline [IsoSession] Add the isolation_session network test baseline Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs-Attention Requires attention or a decision from the MXC maintainers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants